ContractRecord
Contract
A schema describes the current model. A Contract records previously shipped wire versions and a typed migration from
each version into that model.
Contract.parse selects the declared version, parses its frozen shape, and runs each adjacent migration in order. It
returns Result<'model, ContractError>: the current model, VersionMissing, VersionUnrecognized, VersionTooNew,
ParseFailed (path-aware SchemaErrors for the selected version), or Migration. A migrated value is re-checked
against the current schema, so MigrationError.RevalidationFailed carries path-aware SchemaErrors, while a
MigrationError.MigrationFailed written by your own migration carries only its message string and preserves no paths.
See Versioned Contracts for contract authoring.
Fields
| Name | Type | Description |
|---|---|---|
| Name | Name | No description available. |
| CurrentVersion | CurrentVersion | No description available. |
| CurrentSchema | CurrentSchema | No description available. |
| Source | Source | No description available. |
| Versions | Versions | No description available. |
Specification
Summary
| Name | Signature | Synopsis |
|---|---|---|
| Operations | ||
| create | Contract.create name currentVersion currentSchema | Starts a contract at its current version and schema. |
| supersedes | Contract.supersedes version schema migrate builder | Adds the immediately preceding wire version and its typed migration to the next registered version. |
| build | Contract.build source builder | Finishes a contract with an explicit version-detection strategy. |
| parseVersion | Contract.parseVersion contract version raw | Parses input using an out-of-band version value. |
| parse | Contract.parse contract raw | Detects the input version according to the contract and parses it into the current trusted model. |
| name | Contract.name contract | Returns the contract's stable name. |
| currentVersion | Contract.currentVersion contract | Returns the highest supported version. |
| currentSchema | Contract.currentSchema contract | Returns the schema for the current domain model. |
Operations
Parameters
| Name | Type | Description |
|---|---|---|
| version | int | |
| schema | Schema<'previous> | |
| migrate | 'previous -> Result<'current, MigrationError> | |
| builder | ContractBuilder<'model, 'current> |